#include <iostream>
#define MAX_NUM 1000
using namespace std;

int partition(int (&table)[MAX_NUM+1], int begin, int end){
	int i = begin;
	int j = end;
	int temp = table[i];
	while(i < j){
		while(i < j && table[j] <= temp) j--;
		if(i < j) table[i] = table[j];
		while(i < j && table[i] >= temp) i++;
		if(i < j) table[j] = table[i];
	}
	table[i] = temp;
	return i;
}

int quickSort(int (&table)[MAX_NUM+1], int begin, int end){
	if(begin < end){
		int p = partition(table, begin, end);
		quickSort(table, begin, p-1);
		quickSort(table, p+1, end);
	}
}

int main(){
	int n;
	cin >> n;
	int real[MAX_NUM + 1];
	int table[MAX_NUM + 1];
	for(int i = 1; i <= n; i++)
		cin >> real[i];
	for(int i = 1; i <= n; i++)
		table[i] = real[i];
	int count = n;
	int result = 0;
	while(count > 1){
		quickSort(table, 1, n);
		int i = n;
		while(table[i] == -1) i--;
		table[i] = table[i] + table[i-1];
		result = result + table[i] - 1;
		table[i-1] = -1;
		count--;
	}
	cout << result << endl;
	count = n;
	result = 0;
	while(count > 1){
		quickSort(real, 1, n);
		int i = 1;
		while(real[i] == -1) i++;
		real[i] = real[i] + real[i+1];
		result = result + real[i] - 1;
		real[i+1] = -1;
		count--;
	}
	cout << result << endl;
}
